package com.ziyun.erp.common.utils;

import com.utility.New;
import com.ziyun.erp.modules.goods.entity.GoodsProductEntity;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.xssf.usermodel.XSSFRow;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;

import java.io.IOException;
import java.io.InputStream;
import java.util.List;

/**
 * 商品批量改价工具类
 * @author xueqz
 * @email
 * @date 2018-11-26 10:18:24
 */
public class GoodsPriceUtils {

    /**
     * 解析excle input流返回包装类
     * @param inputStream
     */
    public static List<GoodsProductEntity> analysisExcle(InputStream inputStream) throws Exception {

        List<GoodsProductEntity> goodsProductList = New.arrayList();
        XSSFWorkbook xssfWorkbook = new XSSFWorkbook(inputStream);
        if(xssfWorkbook == null){
            throw new Exception("未读取到内容,请检查路径！");
        }
        for(int numSheet = 0;numSheet< xssfWorkbook.getNumberOfSheets();numSheet++){
            //获得每一个sheet
            XSSFSheet xSSSheet = xssfWorkbook.getSheetAt(numSheet);
            if(xSSSheet == null){
                continue;
            }
            for(int rowNum = 0;rowNum < xSSSheet.getLastRowNum();rowNum++){
                //获得每一行的数据
                XSSFRow rowData = xSSSheet.getRow(rowNum);
                for(int columnNum = 0;columnNum<10;columnNum++){

                }


            }

        }



        return goodsProductList;
    }

}
